﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace eOrdered.Helpers
{
    public static class MobileHelper
    {
        public static bool IsMobileDevice(this ControllerContext c)
        {
            return c.HttpContext.Request.Browser.IsMobileDevice;
        }
        
        public static void AddGenericMobile<T>(this ViewEngineCollection ves) where T : IViewEngine, new()
        {
            ves.Add(new CustomViewEngine(new T(), c => c.HttpContext.Request.Browser.IsMobileDevice  ,"mobile"));
        }

        public static void AddDesktop<T>(this ViewEngineCollection ves) where T : IViewEngine, new()
        {
            ves.Add(new CustomViewEngine(new T(), c => (!c.HttpContext.Request.Browser.IsMobileDevice), "desktop"));
        }
    }
}